package com.example.demo.service;

import com.example.demo.dao.Creation;
import com.example.demo.domain.SysRoleMenu;
import com.example.demo.dao.SysRoleMenuDao;
import com.example.demo.service.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service
@Transactional
public class SysRoleMenuService extends BaseService<SysRoleMenu, SysRoleMenuDao>{
    @Override
    public void batchInsert(List<SysRoleMenu> list) {
        if(list.size() <= 0)
            return;



        super.deleteByCreations(new Creation("role_id", Creation.Operation.eq, list.get(0).getRoleId()));

        list.forEach(sysRoleMenu -> {
            sysRoleMenu.setId(UUID.randomUUID().toString());
        });
        super.batchInsert(list);
    }
}